<div [@routerTransition]>
    <div class="m-subheader">
        <div class="row align-items-center">
            <div class="mr-auto col-auto">
                <h3 class="m-subheader__title m-subheader__title--separator">
                    <span>任务</span>
                </h3>
                <span class="m-section__sub">
                    {{"TasksHeaderInfo" | localize}}
                </span>
            </div>
        </div>
    </div>
    <div class="m-content">
        <div class="m-portlet m-portlet--mobile" style="margin: 0;">
            <div class="m-portlet__body" style="height: 724px;">
                <form class="horizontal-form" autocomplete="off">
                    <div class="m-form m-form--label-align-right">
                        <div class="row align-items-center m--margin-bottom-10">
                            <div class="col-xl-12" style="padding: 0;">
                                <div class="form-group m-form__group align-items-center">
                                    <div class="input-group">
                                        <input [(ngModel)]="filterText" name="filterText" autoFocus class="form-control m-input"
                                            [placeholder]="l('SearchWithThreeDot')" type="text">
                                        <span class="input-group-btn">
                                            <button (click)="getTasks()" class="btn btn-primary" type="submit"><i class="flaticon-search-1"
                                                    [attr.aria-label]="l('Search')"></i></button>
                                        </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row m--margin-bottom-10" [hidden]="!advancedFiltersAreShown">
                            <div class="col-md-6" style="padding: 0;">
                                <div class="m-checkbox-list">
                                    <label for="UsersTable_OnlyLockedUsers" class="m-checkbox">
                                        <p-dropdown name="selectSecret" [options]="taskTypeAyy" [(ngModel)]="taskType"
                                            [style]="{ width: '360px' }"></p-dropdown>
                                    </label>
                                </div>
                            </div>
                        </div>

                        <!-- <div class="row margin-bottom-10" *ngIf="advancedFiltersAreShown">
                            <div class="col-sm-12 text-right">
                                <button class="btn btn-metal" (click)="getUsers()"><i class="fa fa-sync"></i>
                                    {{"Refresh" | localize}}</button>
                            </div>
                        </div> -->
                        <div class="row margin-bottom-10">
                            <div class="col-sm-12">
                                <span class="clickable-item text-muted" *ngIf="!advancedFiltersAreShown" (click)="advancedFiltersAreShown=!advancedFiltersAreShown"><i
                                        class="fa fa-angle-down"></i> {{"ShowAdvancedFilters" | localize}}</span>
                                <span class="clickable-item text-muted" *ngIf="advancedFiltersAreShown" (click)="advancedFiltersAreShown=!advancedFiltersAreShown"><i
                                        class="fa fa-angle-up"></i> {{"HideAdvancedFilters" | localize}}</span>
                            </div>
                        </div>

                    </div>
                </form>

                <div class="row align-items-center">
                    <!--<Primeng-TurboTable-Start>-->
                    <div class="primeng-datatable-container" [busyIf]="primengTableHelper.isLoading">
                        <p-table #dataTable (onLazyLoad)="getTasks($event)" [value]="primengTableHelper.records" rows="{{primengTableHelper.defaultRecordsCountPerPage}}"
                            [paginator]="false" [lazy]="true" [sortField]="code" [scrollable]="true" ScrollWidth="100%"
                            [responsive]="primengTableHelper.isResponsive" [resizableColumns]="primengTableHelper.resizableColumns">
                            <ng-template pTemplate="header">
                                <tr>
                                    <th style="width: 50px">
                                        序号
                                    </th>
                                    <th style="width: 150px">
                                        任务号
                                    </th>
                                    <th style="width: 150px">
                                        名称
                                    </th>
                                    <th style="width: 150px">
                                        图号
                                    </th>
                                    <th style="width: 150px">
                                        工艺路线
                                    </th>
                                    <th style="width: 150px">
                                        型号
                                    </th>
                                    <th style="width: 200px">
                                        任务数量
                                    </th>
                                    <th style="width: 200px">
                                        交付时间
                                    </th>
                                    <th style="width: 120px">
                                        外协申请
                                    </th>
                                    <th style="width: 120px">
                                        加工/交付
                                    </th>
                                    <th style="width: 200px">
                                        备注
                                    </th>
                                </tr>
                            </ng-template>
                            <ng-template pTemplate="body" let-record="$implicit" let-ri="rowIndex">
                                <tr>
                                    <td style="width: 50px">
                                        {{ri+1}}
                                    </td>
                                    <td style="width: 150px">
                                        {{record.taskCode}}
                                    </td>
                                    <td style="width: 150px">
                                        {{record.drawingName}}
                                    </td>
                                    <td style="width: 150px">
                                        {{record.drawingCode}}
                                    </td>
                                    <td style="width: 150px">
                                        {{record.processRoute}}
                                    </td>

                                    <td style="width: 150px">
                                        {{record.modelCode}}
                                    </td>
                                    <td style="width: 200px">
                                        {{record.totalQuantity}}
                                    </td>
                                    <td style="width: 200px">
                                        {{record.dueDate | momentFormat:'L'}}
                                    </td>
                                    <td style="width: 120px">
                                        <div [ngSwitch]="record.outsourcingNum">
                                            <div *ngSwitchCase="">
                                                <div class="m-loader m-loader--warning" style="width: 30px; display: inline-block;"></div>
                                            </div>
                                            <div *ngSwitchDefault>
                                                <!-- <span class="m--font-bold">

                                                        </span> -->
                                                <span class="label m-badge m-badge--success m-badge--wide" *ngIf="record.processingNum >= record.totalQuantity">
                                                    {{record.totalQuantity}}/{{record.outsourcingNum}}</span>

                                                <span class="label m-badge m-badge--default m-badge--wide" *ngIf="record.processingNum < record.totalQuantity">
                                                    {{record.totalQuantity}}/{{record.outsourcingNum}}</span>
                                            </div>
                                        </div>

                                    </td>
                                    <td style="width: 120px">
                                        <div [ngSwitch]="record.processingNum">
                                            <div *ngSwitchCase="">
                                                <div class="m-loader m-loader--warning" style="width: 30px; display: inline-block;"></div>
                                            </div>
                                            <div *ngSwitchDefault>
                                                <span class="label m-badge m-badge--success m-badge--wide" *ngIf="record.processingNum >= record.totalQuantity">
                                                    {{record.processingNum}} / {{record.deliveryNum}}</span>

                                                <span class="label m-badge m-badge--default m-badge--wide" *ngIf="record.processingNum < record.totalQuantity">
                                                    {{record.processingNum}} / {{record.deliveryNum}}</span>
                                            </div>
                                        </div>

                                    </td>
                                    <td style="width: 200px">
                                        {{record.remark}}
                                    </td>
                                </tr>
                            </ng-template>
                        </p-table>
                        <div class="primeng-no-data" *ngIf="primengTableHelper.totalRecordsCount == 0">
                            {{'NoData' | localize}}
                        </div>
                        <div class="primeng-paging-container">
                            <p-paginator [rows]="primengTableHelper.defaultRecordsCountPerPage" #paginator
                                (onPageChange)="getTasks($event)" [totalRecords]="primengTableHelper.totalRecordsCount"
                                [rowsPerPageOptions]="primengTableHelper.predefinedRecordsCountPerPage">

                            </p-paginator>
                            <span class="total-records-count">
                                {{'TotalRecordsCount' | localize:primengTableHelper.totalRecordsCount}}
                            </span>
                        </div>
                    </div>
                    <!--<Primeng-TurboTable-End>-->
                </div>
            </div>
        </div>
    </div>


    <!-- <createOrEditTaskModal #createOrEditTaskModal (modalSave)="getTasks()"></createOrEditTaskModal>
    <editUserPermissionsModal #editUserPermissionsModal></editUserPermissionsModal> -->
</div>
